package com.len.service.impl;

import com.len.base.BaseMapper;
import com.len.base.impl.BaseServiceImpl;
import com.len.entity.Behavior;
import com.len.mapper.BehaviorMapper;
import com.len.service.BehaviorService;
import com.len.util.ReType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author songxiangyang
 * @date 2019/03/15.
 */
@Service
public class BehaviorServiceImpl extends BaseServiceImpl<Behavior,String> implements BehaviorService {

  @Autowired
  private BehaviorMapper behaviorMapper;

  @Override
  public BaseMapper<Behavior, String> getMappser() {
    return behaviorMapper;
  }

  @Override
  public int deleteByPrimaryKey(String id) {
    return behaviorMapper.deleteByPrimaryKey(id);
  }

  @Override
  public int insert(Behavior record) {
    record=super.addValue(record,true);
    return behaviorMapper.insert(record);
  }
  
  @Override
  public Behavior selectByPrimaryKey(String id) {
    return behaviorMapper.selectByPrimaryKey(id);
  }

  @Override
  public int updateByPrimaryKeySelective(Behavior record) {
    return behaviorMapper.updateByPrimaryKeySelective(record);
  }

  @Override
  public int updateByPrimaryKey(Behavior record) {
    return behaviorMapper.updateByPrimaryKey(record);
  }

  @Override
  public List<Behavior> selectListByPage(Behavior behavior) {
    return behaviorMapper.selectListByPage(behavior);
  }

  @Override
  public ReType selectBehaviorList(Behavior behavior) {
    ReType reType = new ReType();
    Example example = new Example(Behavior.class);
    example.createCriteria().andEqualTo("channelId", behavior.getChannelId());
    List<Behavior> behaviors = behaviorMapper.selectByExample(example);
    reType.setData(behaviors);
    return reType;
  }

  @Override
  public int selectCountByCondition(Behavior behavior) {
    return behaviorMapper.selectCountByCondition(behavior);
  }
}
